package com.example.ry.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.ry.bean.ParamsData;

/**
 * 统一异常拦截
 */
@ControllerAdvice
public class DefaultExceptionHandler {

	@ExceptionHandler(AuthorizationException.class)
	@ResponseBody
	public String handleAuthorizationException(AuthorizationException e) {
		System.out.println("异常：没有权限，已被拦截处理");
		ParamsData pd=new ParamsData();
		pd.put("msg", e.getMessage());
		pd.put("error type", "AuthorizationException");
		return "没有权限";
	}
	
}
